Code cells¶
This first code cells have some tags
In [1]:
Copied!
a = 1
a = 1
In [2]:
Copied!
a
a
Out[2]:
1
In [3]:
Copied!
b = 'pew'
b = 'pew'
In [4]:
Copied!
b
b
Out[4]:
'pew'
In [5]:
Copied!
import re
import re
In [6]:
Copied!
text = 'foo bar\t baz \tqux'
text = 'foo bar\t baz \tqux'
In [7]:
Copied!
re.split('\s+', text)
re.split('\s+', text)
<>:1: SyntaxWarning: invalid escape sequence '\s'
<>:1: SyntaxWarning: invalid escape sequence '\s'
/var/folders/jh/kqmryfv53533wx83vdhl_5zr0000gn/T/ipykernel_89452/1439998361.py:1: SyntaxWarning: invalid escape sequence '\s'
re.split('\s+', text)
Out[7]:
['foo', 'bar', 'baz', 'qux']
Equations¶
In [8]:
Copied!
%%latex
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}
%%latex \begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}
\begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}
Pandas DataFrames¶
In [9]:
Copied!
import numpy as np
import pandas as pd
import numpy as np import pandas as pd
In [10]:
Copied!
dates = pd.date_range('20130101', periods=6)
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD'))
df
dates = pd.date_range('20130101', periods=6) df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD')) df
Out[10]:
| A | B | C | D | |
|---|---|---|---|---|
| 2013-01-01 | 0.064687 | -1.064990 | -0.081865 | 0.430260 |
| 2013-01-02 | -0.388568 | -0.974757 | -0.477194 | 2.163054 |
| 2013-01-03 | 0.549508 | -1.315100 | 3.105967 | 1.957135 |
| 2013-01-04 | -0.368952 | -0.430743 | -1.197150 | -0.730688 |
| 2013-01-05 | -0.323770 | -1.294550 | 0.627769 | 1.036026 |
| 2013-01-06 | 0.625761 | -0.384097 | -1.924062 | -0.058176 |
Plots¶
In [11]:
Copied!
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
In [12]:
Copied!
from pylab import *
from pylab import *
In [13]:
Copied!
x = linspace(0, 5, 10)
y = x ** 2
x = linspace(0, 5, 10) y = x ** 2
This is some text, here comes some latex
bokeh¶
In [16]:
Copied!
from bokeh.plotting import figure, output_notebook, show
from bokeh.plotting import figure, output_notebook, show
In [18]:
Copied!
p = figure()
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)
show(p)
p = figure() p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2) show(p)
plotly¶
This requires a theme modification to include Require.JS
In [19]:
Copied!
import plotly.express as px
import plotly.express as px
In [20]:
Copied!
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.show()
df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length") fig.show()
Widgets¶
In [21]:
Copied!
import ipywidgets as widgets
import ipywidgets as widgets
In [22]:
Copied!
widget = widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
value_lbl = widgets.Label()
widgets.jslink((widget, 'value'), (value_lbl, 'value'))
display(widget, widgets.HBox([widgets.Label("Current Value:"), value_lbl]) )
widget = widgets.IntSlider( value=7, min=0, max=10, step=1, description='', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d' ) value_lbl = widgets.Label() widgets.jslink((widget, 'value'), (value_lbl, 'value')) display(widget, widgets.HBox([widgets.Label("Current Value:"), value_lbl]) )